package com.swipemaster.dialogs;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.swipemaster.R;
import com.swipemaster.common.Global;

public class CustomToast
{
	private final Toast toast;
	private final TextView firstText;
	private final ImageView star;
	private final TextView secondText;

	@SuppressLint("ShowToast")
	public CustomToast(Activity activity)
	{
		toast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
		toast.setGravity(Gravity.CENTER, 0, 0);

		final LayoutInflater inflater = activity.getLayoutInflater();
		final View toastLayout = inflater.inflate(R.layout.toast_layout, null);
		toastLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		toast.setView(toastLayout);

		firstText = (TextView) toastLayout.findViewById(R.id.toast_text);
		star = (ImageView) toastLayout.findViewById(R.id.toast_star);
		secondText = (TextView) toastLayout.findViewById(R.id.toast_text2);
	}

	public void showYouNeedStars(int stars)
	{
		firstText.setText(String.format(Global.app.getString(R.string.you_need), stars));
		star.setVisibility(View.VISIBLE);
		secondText.setVisibility(View.VISIBLE);
		toast.show();
	}

	public void showCompleteLevel(int levelIndex)
	{
		firstText.setText(String.format(Global.app.getString(R.string.complete_level), levelIndex + 1));
		star.setVisibility(View.GONE);
		secondText.setVisibility(View.GONE);
		toast.show();
	}

}
